{% extends site.theme|stringformat:"s/include/base.html" %}
{% block title %}{{product.title}} - {% endblock %}{% block mainer %}
<table class="mainlist"><tr><td class="sidebar">
{% include site.theme|stringformat:"s/include/sidebar.html" with catalogList=site.catalogs %}
</td><td>{% include site.theme|stringformat:"s/include/location.html" with lists=lctList %}
	<table class="prdDetail">
		<tr class="formTr"><td rowspan="2" style="width:300px; text-align: center;"><img class="prdimg" src="{{product.frontcover}}" /></td><td><b>{{product.title}}</b></td></tr>
		<tr class="formTr"><td>{{product.content}}</td></tr>
	</table>
	<table width="100%" class="editTable">
		<thead><tr><th colspan="2"><div>参数指标</div></th></tr></thead>{% for e in paramList %}
		<tr id="p-{{e.id}}" class="formTr"><th>{{e.title}}：</th><td>{{e.value}}{{e.value1|default:''}}</td></tr>
	{% endfor %}</table>
	<div class="prdFooter"><span style="float: left;">固定链接：</span>浏览数：{{ product.readcnt }}&nbsp;&nbsp;&nbsp;评论数：{{ product.commentcnt }}{% if site.power.user.power >= 100 %}&nbsp;&nbsp;&nbsp;<a href="javascript:del('','Product',{{product.id}});">删除</a>&nbsp;&nbsp;&nbsp;<a href="/edit!Product-{{product.id}}.html">编辑</a>{% endif %}</div>
	{% if product.isComment %}<div class="clear"></div>
	<table id="comments">
	  <tr>
	  	<td>
	  		<div class="cmtTitle"><span>评论({{cmtList|length}})</span></div>
	    	<div id="commentlist">
				{% for e in cmtList %}<div id="e-{{e.id}}" class="comment">
			    	<div class="commentTitle"><span style="float: left; white-space:nowrap; "><img alt="{{ e.author }}" src="/static/{{site.theme}}/images/avatar.gif"> 作者：<a href="{{e.homepage|default:'#'}}">{{ e.author }}</a><br /> 发表于: {{ e.date|date:"Y-m-d H:i:s" }}</span>
			    		<span style="float:right; font-weight: normal; text-align: right; line-height:20px; margin-top:-3px;"><a href="#{{forloop.counter}}">#{{forloop.counter}}</a><br /> {% if site.power.user.power >= 100 %}<a href="javascript:deleteByID('/delCmt!Product-{{e.id}}.do', 'e-{{e.id}}');">删除</a>&nbsp;&nbsp;&nbsp;{% endif %}<a href="javascript:showreplay({{e.id}});">回复</a></span></div>
			    	<div class="commentContent">{{ e.content|default:'' }}</div>
				    {% for e2 in cmtList2 %}{% if e2.pid = e.id %}<div id="e-{{e2.id}}" class="comment reply">
				    	<div class="commentTitle"><span style="float: left; white-space:nowrap; "><img alt="{{ e2.author }}" src="/static/{{site.theme}}/images/avatar.gif"> 作者：<a href="{{e2.homepage|default:'#'}}">{{ e2.author }}</a><br /> 发表于: {{ e2.date|date:"Y-m-d H:i:s" }}</span>
				    		<span style="float:right; font-weight: normal; text-align: right; line-height:20px; margin-top:-3px;"><a href="#{{forloop.counter}}">#{{forloop.counter}}</a>这是一个回复<br /> {% if site.power.user.power >= 100 %}<a href="javascript:deleteByID('/delCmt!Article-{{e2.id}}.do', 'e-{{e2.id}}');">删除</a>{% endif %}</span></div>
				    	<div class="commentContent">{{ e2.content|default:'' }}</div>
				    </div>{% endif %}{% endfor %}</div>{% empty %}暂时没有评论！{% endfor %}
			</div>
			{% include site.theme|stringformat:"s/include/pager.html" with pager=pager %}
	 </td></tr>
	 <tr><td id="newtd">
			<div id="newcomment"><form id="newCmtForm">
			<div class="cmtTitle"><span>发表评论</span><span id="closenewcmt" class="closenew"><a href="javascript:closenew();">关闭</a></span></div>
				<table class="commentTable">
					<tr><td class="cmtLabel">{{cmtForm.author.label}}（必填）：</td><td style="width: 180px;">{{cmtForm.author}}</td><td rowspan="4" style="width:440px; text-align:center;">{{cmtForm.content}}</td></tr>
					<tr><td class="cmtLabel">{{cmtForm.email.label}}（必填）：</td><td>{{cmtForm.email}}</td></tr>
					<tr><td class="cmtLabel">{{cmtForm.homepage.label}}（可选项）：</td><td>{{cmtForm.homepage}}</td></tr>
					{% include site.theme|stringformat:"s/include/safecode.html" with safecode=loginForm.safecode etype='article' %}
					<tr><td class="cmtLabel"></td><td></td><td style="padding-left: 20px;"><input type="button" value="提交" OnClick="addComment();"><input id="btmReset" type="reset" value="重置"><input name="_retType"  id="_retType" type="Hidden" value="json"><input name="pid"  id="id_pid" type="Hidden" value="-1"></td></tr>
				</table></form>
				<script type="text/javascript">
				<!--
				var myContent = '填写{{cmtForm.content.label}}......';
				initCmt();
				function initCmt(){
					$('#id_content').val(myContent);
					$('#id_content').bind({
						focusin: function(){if($('#id_content').val()==myContent){$('#id_content').val('');}},
						focusout: function(){if($('#id_content').val()==''){$('#id_content').val(myContent);}}
					});
				}
				function addComment(){
					var pid = $('#newcomment #id_pid').val();
					$.dialog.confirm('确定要发表此评论么?',
							function(){
								if($('#id_content').val()==myContent){$('#id_content').val('');}
								if(pid == '-1')$('#commentlist').append("<div id='loading'>Loading......</div>");
								else  $('#e-'+pid).append("<div id='loading'>Loading......</div>");
								var url="/addCmt!Product-{{product.id}}.do";
								$.post(url, $('#newCmtForm').serialize(),function (data){
									if(data.flag){$.dialog.alert(data.msg, function(){
										if($('#newcomment #id_pid').val() == '-1')$('#commentlist').append(data.html);
										else $('#e-'+$('#newcomment #id_pid').val()).append(data.html);
										$('#loading').remove();$('#btmReset').click();reloadSCimage();});
									}
									else {$.dialog.alert(data.msg);$('#loading').remove();}
									if($('#id_content').val()==''){$('#id_content').val(myContent);}
								},'json');
							},
							function(){}
					);
				}
				function showreplay(id){
					$('#e-'+id).after($('#newcomment'));
					$('#newcomment #id_pid').val(id);
					$('#closenewcmt').show();
				}
				function closenew(){
					$('#newtd').html($('#newcomment'));
					$('#newcomment #id_pid').val('-1');
					$('#closenewcmt').hide();
				}
				//-->
				</script>
			</div>
	    </td></tr>
	</table>{% endif %}
</td></tr></table>
{% endblock %}